﻿@using Covenant.Core
@using Covenant.Models.Grunts
@using Covenant.Models.Listeners
@using Covenant.Models.Launchers
@model Launcher
@{
    IEnumerable<Listener> Listeners = ViewBag.Listeners;
    IEnumerable<ImplantTemplate> ImplantTemplates = ViewBag.ImplantTemplates;
}

<form asp-action="@Model.Name">
    <div asp-validation-summary="All" class="text-danger"></div>
    <input asp-for="@Model.Id" value="@Model.Id" type="hidden">
    <input asp-for="@Model.Type" type="hidden" name="Type" value="@Model.Type">
    <div class="form-group">
        <label asp-for="@Model.Description"></label>
        <input asp-for="@Model.Description" value="@Model.Description" class="form-control-plaintext" readonly>
    </div>
    <div class="form-row">
        <div class="form-group col-md-6">
            <label asp-for="@Model.ListenerId">Listener</label>
            <select asp-for="@Model.ListenerId" class="form-control">
                @foreach (var item in Listeners)
                {
                    @if (item.Status == ListenerStatus.Active)
                    {
                        <option value="@item.Id">@Html.DisplayFor(modelItem => item.Name)</option>
                    }
                }
            </select>
        </div>
        <div class="form-group col-md-6">
            <label asp-for="@Model.ImplantTemplateId">Template</label>
            <select asp-for="@Model.ImplantTemplateId" class="form-control">
                @foreach (var item in ImplantTemplates)
                {
                    <option value="@item.Id">@Html.DisplayFor(modelItem => item.Name)</option>
                }
            </select>
        </div>
    </div>
    <div class="form-row" id="http-div">
        <div class="form-group col-md-6">
            <label asp-for="@Model.ValidateCert"></label>
            <select asp-for="@Model.ValidateCert" class="form-control">
                <option>True</option>
                <option>False</option>
            </select>
        </div>
        <div class="form-group col-md-6">
            <label asp-for="@Model.UseCertPinning"></label>
            <select asp-for="@Model.UseCertPinning" class="form-control">
                <option>True</option>
                <option>False</option>
            </select>
        </div>
    </div>
    <div class="form-group" id="smb-div" hidden>
        <label asp-for="@Model.SMBPipeName"></label>
        <input asp-for="@Model.SMBPipeName" value="@Model.SMBPipeName" class="form-control">
    </div>
    <div class="form-row">
        <div class="form-group col-md-6">
            <label asp-for="@Model.Delay"></label>
            <input asp-for="@Model.Delay" value="@Model.Delay" class="form-control">
        </div>
        <div class="form-group col-md-6">
            <label asp-for="@Model.JitterPercent"></label>
            <input asp-for="@Model.JitterPercent" value="@Model.JitterPercent" class="form-control">
        </div>
    </div>
    <div class="form-row">
        <div class="form-group col-md-4">
            <label asp-for="@Model.ConnectAttempts"></label>
            <input asp-for="@Model.ConnectAttempts" value="@Model.ConnectAttempts" class="form-control">
        </div>
        <div class="form-group col-md-4">
            <label asp-for="@Model.KillDate"></label>
            <input id="KillDate" name="KillDate" value="@Model.KillDate" class="form-control">
        </div>
        <div class="form-group col-md-4">
            <label asp-for="DotNetFrameworkVersion"></label>
            <select asp-for="DotNetFrameworkVersion" asp-items="Html.GetEnumSelectList<Common.DotNetVersion>()" class="form-control"></select>
        </div>
    </div>
    <input asp-for="@Model.LauncherString" value="@Model.LauncherString" class="form-control" type="hidden">
    <input asp-for="@Model.StagerCode" value="@Model.StagerCode" class="form-control" type="hidden">
    <input asp-for="@Model.Base64ILByteString" value="@Model.Base64ILByteString" class="form-control" type="hidden">
    @{
        List<string> launchernames = new List<string> { "Binary", "CScript", "InstallUtil", "MSBuild", "Mshta", "PowerShell", "Regsvr32", "Wmic", "WScript" };
        if (launchernames.Contains(Model.Name))
        {
            await Html.RenderPartialAsync("_" + Model.Name + "Form", Model);
        }
    }
    <div class="btn-group" role="group">
        <button type="submit" class="btn btn-primary mr-5" id="generate"><span data-feather="zap"></span> Generate</button>
        <button type="button" class="btn btn-outline-primary ml-5" id="download"><span data-feather="download"></span> Download</button>
    </div>
</form>